package ai.people.netmon.auth.service;

import ai.people.netmon.framework.domain.ucenter.ext.IssueToken;
import ai.people.netmon.framework.domain.ucenter.request.LoginRequest;
import ai.people.netmon.framework.domain.ucenter.request.LoginUser;
import org.springframework.util.Base64Utils;

import java.io.IOException;
import java.util.Map;

/**
 * 身份验证服务
 *
 * @author yuanqinglong
 * @date 2022/2/21 13:07
 */
@Deprecated
public interface AuthenticateService {

    /**
     * 进行身份验证
     *
     * @param loginRequest @return {@link String}
     * @return {@link IssueToken}
     */
    Map<String, Object> authenticate(LoginRequest loginRequest) throws IOException;


    /**
     * 刷新令牌
     *
     * @param refreshToken 刷新令牌
     * @return {@link IssueToken}
     */
    Map<String, Object> refreshToken(String refreshToken) throws IOException;


    /**
     * 检查令牌
     *
     * @param token 令牌
     * @return {@link LoginUser}
     */
    LoginUser checkToken(String token);




    /**
     * 注销
     *
     * @param token 令牌
     */
    void logout(String token);


    default String getHttpBasic(String clientId, String clientSecret) {
        String string = clientId + ":" + clientSecret;
        //将串进行base64编码
        byte[] encode = Base64Utils.encode(string.getBytes());
        return "Basic " + new String(encode);
    }

}
